home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / MAL38.ZIP;1 / FOXPRO.ZIP / Q_README.TXT < prev    next >
Encoding:
Text File  |  1992-01-15  |  14.6 KB  |  337 lines

  1.  
  2. ***********************
  3.  
  4. SEE: HOW TO USE THE EXPRESSION BUILDER in this file for a quick start.
  5. ***********************
  6.  
  7. I can be reached on FoxForum (Robert Pope 72030,3032) for questions.
  8.  
  9.  
  10. This file describes the custom expression building facility.
  11.  
  12. The facility consists of two parts. The DATA_BLD program and the expression builder EXPRMENU.
  13.  
  14. 1.DATA_BLD program. 
  15.         
  16.   The DATA_BLD.prg is used by the developer to create the necessary data files (DBF) if they have not been created.
  17.     
  18.   Those DBF files are Q_DATA,Q_EXPR,Q_PHRASE and a file(s) to be named by the developer that contains the field lookup data for the expression builder picklist. 
  19.  
  20.  
  21.   Q_DATA.DBF is a data dictionary that DATA_BLD builds from the current environment. Fields from the master data base and all related
  22.   data bases (directly related or indirectly related) are included. Unrelated data files are not included.
  23.   
  24.   You can also build a picklist by starting DATA_BLD... Do DATA_BLD and selecting the "Create New Picklist" option.
  25.  
  26.   When the DATA_BLD program is started, the developer is given a chance to re-label the data base names for use in expression picklists. This should make it easier for the user to understand what they are picking.
  27.   Example: Change label for CUST(DBF) to Customer.
  28.  
  29.  
  30.   The developer is given a chance to change (browse) the Field_label and the picture clause for each field used in the expression builder. Fields may also be removed from the list by deleting them. This will remove unnecessary fields or fields that would be confusing to the user.
  31.  
  32.   
  33.   Screen files (SCX) may be used to provide PICTURE clauses for fields and also generate code for popups from the SCX file. If the screen file has the same name as the DBF alias, then you can check the box labeled "Use field_name DBF alias as SCX file name" and DATA_BLD will look for the matching SCX file. EXAMPLE: DBF alias="FAMILY" and the screen file is "FAMILY.SCX".
  34.  
  35.  
  36.   If the FIELD_PICT is not empty, the picture clause in the screen file file will be ignored except when "^" is in FIELD_PICT. Logical field picture clauses will be ignored.
  37.   
  38.   If the same screen file is used for all the fields in the picklist but it doesn't match the DBF alias, then you can check the box that says "Use SCX file to initialize picture clauses". Then type the name of that screen file in the "SCX file name" field.
  39.  
  40.  
  41.   Finally, if you have fields from several DBFs and thay are in different screen files and the screen files don't match the corresponding DBF aliases, you can type the name of the appropriate SCX file in the field
  42.   FIELD_SCX when you get into modifying the picklist (browse) and DATA_BLD
  43.   will look in those SCX files for picture and popup information.
  44.   
  45.   
  46.   The term "popup" may be misleading because DATA_BLD will look for Radio Buttons and array picklist as well. If it finds them it will convert that information into code that generates matching popups... used by EXPRMENU
  47.   in the form ....  FIELD OPERATOR DATA, but the data will be a popup instead of a GET that the user types in.
  48.  
  49.   If you use screen files to initialize the picture clauses, just modify field labels then press < F10 > to build the picklist. To see what you've done, just Do DATA_BLD and choose the "Modify Current Picklist" option.
  50.  
  51.   
  52.   Structure for database : q_data.dbf
  53.   Field  Field Name  Type       Width  Dec
  54.      1  FIELD_NAME  Character     20
  55.      2  FIELDLABEL  Character     30
  56.      3  FIELD_TYPE  Character      1
  57.      4  FIELD_LEN   Numeric        3   0
  58.      5  FIELD_PICT  Character     25
  59.      6  FIELD_SCX   Character     12 .... holds SCX file name
  60.      7  FIELD_DEC   Numeric        3   0
  61.      8  FIELD_MEM   Memo          10 .... holds popup/radio button options
  62.      9  SCX_FIELD   Character     12 .... holds name of memvar used in
  63.                                           place of field name in SCX file
  64.                                           Not needed if memvar same as
  65.                                           field...Example: Field="NCAT" and
  66.                                           GET="m.ncat"            
  67.     10  ARRAY_CODE  Memo          10 .... holds code used to generate code
  68.                                           for array popups 
  69.  
  70.   DATA_BLD will attempt to genarate code for array type popups with code that takes the form.....
  71.  
  72.  
  73.     priv was_used
  74.     was_used=.f.
  75.     If used("LASER")
  76.       was_used=.t.
  77.     Endif
  78.     Select Distinct STUDIO ;   && generates array popup for Studio field
  79.      order by STUDIO ;
  80.      from LASER ;
  81.      where !deleted() and !empty(STUDIO) ;
  82.      into array choice         && array name must remain "CHOICE"
  83.      If !was_used
  84.        use in LASER
  85.      Endif
  86.  
  87.   
  88.   
  89.   This code is stored in the ARRAY_CODE field and can be modified to suit the developers needs. 
  90.   
  91.   WARNING! Array name must remain "CHOICE"!
  92.  
  93.  
  94.   The developer may type their own SQL code in ARRAY_CODE or their own picklist choices in FIELD_MEM ( make sure the last picklist choice is
  95.   not followed by a chr(13)/< ENTER > or you will get a blank choice in the picklist.
  96.   
  97.   
  98.   To re-edit the Q_data data dictionary just rerun the DATA_BLD program.
  99.   DATA_BLD will continue  to use the existing q_data.dbf. This allows correction of mistakes in picture clauses and field labels without
  100.   having to start over again. 
  101.   
  102.   NOTE: Mistakes in picture clauses is the most likely cause for the expression builder to bomb.
  103.  
  104.  
  105.   NOTE: When first modifying a picklist DBF (Q_DATA), you can choose "Recno()" as an option to reorder the picklist in Recno() order. However, if you have previously ordered the picklist alphabetically and written it to disk. The Recno() order option will return it to the alphabetical order since the record numbers will then correspond to the alphabetical order.
  106.   If you use the "Arrange" option, then "Recno()" will return the file to the arranged order even if the picklist file has not been written to disk.
  107.  
  108.   To make a new picklist program and data file for another view/environment,
  109.   just open the new files before running the DATA_BLD program. Be sure to set the file relations and select the master/parent file. You don't have to have any DBFs open to create a picklist. Just start DATA_BLD and choose "Create New Picklist". You may initailize a new picklist with a previously created picklist. DATA_BLD will look for picklist with names that match the selected DBF and ask if you want to use them to initailize the current picklist. Example: DBF="FAMILY" and an existing picklist file = "QFAMILY". I recommend using the alias with a "Q" prefix as a naming convention for picklist.
  110.  
  111.  
  112.   Also, DATA_BLD will write a program file (named by the developer) that 
  113.   will contain custom code for picklist menus for that    particular 
  114.   application environment, and create a data file (DBF) that contains 
  115.   the data necessary for a picklist. The data file for the picklist will be
  116.   given the same name as the written program so the developer will know
  117.   which picklist program goes with which data_file.
  118.   Example: Program= "QCUSTOM.PRG"  DBF= "QCUSTOM.DBF")
  119.  
  120.   The custom datafile will have the same structure as q_data.
  121.  
  122.   One of the parameters passed to the picklist program by EXPRMENU is "data_pop". If data_pop is passed as true(.t.), the program will use code that uses DEFINE POPUP FIELD for the picklist. If you prefer to uses array style menus(i.e.... not enough open work areas), pass data_pop as false (.f.). Depending on the size of the data files in the view, you may have to increase the MVARSIZ in Config.FP. Large DBFs create large memory consuming arrays.
  123.  
  124.  
  125.   You can control the value of DATA_POP when you start EXPRMENU. If the fifth parameter is passed as .t.,then the picklist DBF file will be used for the field picklist. Otherwise, it will use an array stype picklist created by code in the picklist PRG. This requires more memory but uses less work areas. 
  126.   
  127.  
  128.   The expression builder requires a minimum of 3 open workareas. It requies 2 Read Levels.
  129.  
  130.  
  131.   The Q_EXPR and Q_PHRASE data files contain the expression information.
  132.   Each record in q_expr contains the information for one expression. The
  133.   expression values (phrases) for one expression are contained in 1 or more 
  134.   q_phrase records. 
  135.   
  136.   Q_EXPR and Q_PHRASE are reindexed each time you run EXPRMENU.
  137.  
  138.   Of particular interest in the q_expr DBF is the field entitled "PROGRAM".
  139.   This field is used to tell the expresion builder the current environment.
  140.   It is passed as a parameter to the main program ("EXPRMENU.PRG").
  141.  
  142.   Examples:  my_expr=exprmenu('REPORT','QCUSTOM').
  143.              my_expr=exprmenu(PROGRAM(),'QCUSTOM').
  144.  
  145.  
  146.   NOTE: The 2nd parameter is the name of the custom program created by 
  147.         the DATA_BLD program that contains the picklist for that
  148.         environment.
  149.  
  150.   The q_expr DBF (and q_phrase.dbf) can store the expressions for an entire 
  151.   application, but the "PROGRAM" field tells the expression builder which 
  152.   expressions are appropriate for that particular environment and does not
  153.   show the user the other expressions. 
  154.  
  155.   HINT: A USER ID could be passed as the 1st parameter. This would allow
  156.   each user of the application to have their own set of selection criteria.
  157.   The parameter must be no more than 8 characters long. If there are
  158.   multiple environments in the application, then perhaps part of a USER ID
  159.   plus enough of a character string to identify the environment.
  160.   
  161.   Example: USER ID="1234"  Environment="Reports"  
  162.            Parameter="1234_REP"
  163.           
  164.  
  165.   Structure for database : q_expr.dbf
  166.   Field  Field Name  Type       Width    Dec
  167.      1  EXPR_ID     Character      6
  168.      2  EXPR_NAME   Character     40
  169.      3  PROGRAM     Character      8        && identifies environment of
  170.                                             && calling program
  171.  
  172.      4  FOX_EXPR    Logical        1        && is it a getexpr expression
  173.      5  IG_CASE     Logical        1        && ignore case for expression
  174.      6  EXPR        Memo          10        && store getexpr values
  175.   ** Total **                   00067
  176.  
  177.  
  178.   Structure for database : q_phrase.dbf
  179.   Field  Field Name  Type       Width    Dec
  180.      1  EXPR_ID     Character      6
  181.      2  PHRASE_NO   Numeric        2      0
  182.      3  OPERATOR    Character      2
  183.      4  CONNECTOR   Character      3
  184.      5  Q_FIELD     Character     20
  185.      6  Q_FLABEL    Character     30
  186.      7  Q_FTYPE     Character      1
  187.      8  Q_FLEN      Numeric        3      0
  188.      9  Q_FPICT     Character     25
  189.      10  Q_FDEC      Numeric        3      0
  190.      11  Q_DATA      Character    120
  191.      12  QD_CHOICE   Numeric        1      0
  192.      13  QM_CHOICE   Numeric        1      0
  193.      14  QY_CHOICE   Numeric        1      0
  194.      15  QD_EXPR     Character     30
  195.      16  QM_EXPR     Character     30
  196.      17  QY_EXPR     Character     30
  197.      18  MATH_OP     Character      1
  198.      19  MATH_DATA   Character     60
  199.      20  IGNORECASE  Logical        1
  200.  
  201.  
  202.  
  203. 2.Expression builder program- EXPRMENU
  204.  
  205.  
  206.   ** The following are some of the main procedures in the EXPRMENU program.
  207.   
  208.   Expr_bld.prg- add or edit expressions
  209.   
  210.   Expr_get.prg- builds complete expression from q_phrase records
  211.   
  212.   Qoperate.prg- displays expression operators and returns selected
  213.                 operator
  214.   
  215.   Op2phra.prg-  converts operator into a phrase
  216.                 Example: "==" to "is the same as"
  217.                 
  218.   Phra2op.prg-  converts phrases to operator symbols
  219.   
  220.   Q_date.prg-   builds variable date expression            
  221.   
  222.   Math.prg-     adds math expression to phrase
  223.  
  224.   Indexes are created for the custom picklist DBFs. They are reindexed when the particular picklist DBF is called by EXPRMENU. The reindexing code is
  225.     
  226.     if file('QLASER.CDX')
  227.      delete tag all
  228.     else
  229.      INDEX ON FIELDLABEL TO TAG fieldlabel
  230.     endif
  231.  
  232.  
  233.    After creating a picklist file, you can open it and take a look at what is going on. Example: modify command QLASER.PRG.
  234.  
  235.  
  236. HOW TO USE THE EXPRESSION BUILDER
  237.  
  238.  
  239. 1.  Open the data files and set up the relations
  240. 2.  Make sure the master data base is selected.
  241.  
  242.  
  243.     USE PATIENT INDEX ID
  244.     USE ADDRESS INDEX ADD_ID IN 2
  245.     SET RELATION TO ADD_ID INTO ADDRESS
  246.     GO TOP
  247.     
  248.     DO DATA_BLD ...select "Build Picklist from Enviroment"  
  249.  
  250. 3.  DATA_BLD will show the data file names ("PATIENT","ADDRESS")
  251.     and allow you to re-label them for the expression builder picklist.
  252.     
  253.  
  254. 4.  DATA_BLD will build the data dictionary Q_DATA.DBF from all
  255.     fields in the patient and address files.      
  256.     
  257. 5.  Then you will be able to browse q_data and change the field_labels
  258.     and picture clauses for each field if desired, and delete unwanted
  259.     fields. These changes DO NOT affect the actual data files.
  260.     
  261.  
  262. 6.  It will then call the foxpro putfile() facility so you can name
  263.     the picklist program and data file. The default name supplied will
  264.     be the master DBF file name with a "Q" prefix. I strongly recommend using this naming convention. DATA_BLD is designed to work with it.
  265.     Example: "QPATIENT"
  266.     
  267. 7.  The custom picklist program and data file are created.
  268.  
  269. 8.  Now you are ready to insert the expression builder into your programs.
  270.     
  271.     
  272. 9.    Be sure to look over the HELP topics when you start the exprmenu
  273.     program.
  274.  
  275.  
  276.     
  277. **********************************************************    
  278. ******* SAMPLE PROGRAM
  279. **********************************************************
  280.   SET TALK OFF
  281.   SET STATUS OFF
  282.  
  283. ** supply your files here
  284.  
  285.     USE PATIENT INDEX ID
  286.     USE ADDRESS INDEX ADD_ID IN 2
  287.     SET RELATION TO ADD_ID INTO ADDRESS
  288.  
  289. **
  290.  
  291.     GO TOP
  292.  
  293.  
  294.  
  295.   E_NAME='' && optional parameter that can pass the name of the selected
  296.             && expression back to the calling program                                          
  297.  
  298.  
  299. ** allow e_name to receive selected expression name from expremenu.prg.
  300.   
  301.   SET UDFPARMS TO REFERENCE
  302.  
  303.  
  304.   MY_EXPR=EXPRMENU(PROGRAM(),'QPATIENT',E_NAME)
  305.  
  306.   SET FILTER TO &MY_EXPR
  307.   GO TOP
  308.  
  309.   BROWSE
  310.         
  311.   IF '' <> MY_EXPR
  312.      COUNT TO HOW_MANY FOR &MY_EXPR
  313.      WAIT 'COUNT FOR '+ALLTRIM(E_NAME) +' IS '+ ;
  314.      ALLTRIM(STR(HOW_MANY)) + '. PRESS ANY KEY .. ' WINDOW
  315.   ENDIF
  316.   
  317.  
  318.   CLOSE DATABASES
  319.   RETURN
  320.  
  321.  
  322.  
  323. **************************************
  324. COMMAND LINE TEST
  325. **************************************
  326.  
  327. ** use this to see the actual code that is returned from exprmenu.prg
  328. ** xxxx is a substitute parameter. Be sure to use the same parameters
  329.    when you test it
  330. ** It doesn't have to be xxxx. Any character string will do.
  331.  
  332. ** Q?????? is the name of the picklist program you created with DATA_BLD
  333.  
  334. xx=MY_EXPR=EXPRMENU('XXXX','Q??????')
  335. ? xx
  336.  
  337.